package com.css.dzj.dzjzhfx.modules.totalilty;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.css.dzj.dzjzhfx.common.util.HttpClientUtil;
import com.css.dzj.dzjzhfx.common.util.R;
import com.css.dzj.dzjzhfx.common.util.ServiceUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("/getTotal")
@PropertySource(value = "classpath:config.properties")
@RestController
public class TotalController {
    @Value("${apURL}")
    private String apURL;

    @Value("${xcjyURL}")
    private String xcjyURL;
    /**
     * @param year
     * @return
     */
    @GetMapping("/map")
    public R getTotalByYear(String year, HttpServletRequest request) {
        String[] mapPro = new String[]{"南海诸岛", "北京", "天津", "上海", "重庆", "河北", "河南", "云南", "辽宁", "黑龙江", "湖南", "安徽", "山东", "新疆", "江苏", "浙江", "江西", "湖北", "广西", "甘肃", "山西", "内蒙古", "陕西", "吉林", "福建", "贵州", "广东", "青海", "西藏", "四川", "宁夏", "海南", "台湾", "香港", "澳门"};
        /***
         * 获取检查行为
         */
        String msg = HttpClientUtil.doGet(apURL + "/check/countbyyear?year=" + year);
        JSONObject jsonObject = JSON.parseObject(msg);
        Map<String, Object> mapCheck = new HashMap<>();
        if(!StringUtils.isEmpty(msg)){
            Object count = jsonObject.get("count");
            mapCheck = JSONObject.parseObject(count.toString());
        }
        /**
         * 获取处罚行为
         */
        String msgPunish = HttpClientUtil.doGet(apURL + "/punish/punishyear?year=" + year);
        JSONObject jsonPunish = JSON.parseObject(msgPunish);
        Map<String, Object> mapPunish = new HashMap<>();
        if(!StringUtils.isEmpty(msgPunish)) {
            Object punishOb = jsonPunish.get("count");
            mapPunish = JSONObject.parseObject(punishOb.toString());
        }

        /**
         * 获取强制行为
         */
        String msgForce = HttpClientUtil.doGet(apURL + "/force/forceyear?year=" + year);
        JSONObject jsonForce = JSON.parseObject(msgForce);
        Map<String, Object> mapForce = new HashMap<>();
        if(!StringUtils.isEmpty(msgForce)) {
            Object  forceOb = jsonForce.get("count");
            mapForce = JSONObject.parseObject(forceOb.toString());
        }

        /**
         * 获取其他行为
         */
        String msgOther = HttpClientUtil.doGet(apURL + "/other/otheryear?year=" + year);
        JSONObject jsonOther = JSON.parseObject(msgOther);
        Map<String, Object> mapOther = new HashMap<>();
        if(!StringUtils.isEmpty(msgOther)) {
            Object otherOb = jsonOther.get("count");
            mapOther = JSONObject.parseObject(otherOb.toString());
        }
        /**
         * 获取建设单位
         */
        String msgCon = HttpClientUtil.doGet(apURL + "/constr/countconstryear?year=" + year);
        JSONObject jsonCon = JSON.parseObject(msgCon);
        Map<String, Object> mapCon = new HashMap<>();
        if(!StringUtils.isEmpty(msgCon)) {
            Object constr = jsonCon.get("count");
            mapCon = JSONObject.parseObject(constr.toString());
        }
        /**
         * 获取安评单位
         */
        String msgUnit = HttpClientUtil.doGet(apURL + "/evalunit/countunityear?year=" + year);
        JSONObject jsonUnit = JSON.parseObject(msgUnit);
        Map<String, Object> mapUnit = new HashMap<>();
        if(!StringUtils.isEmpty(msgUnit)) {
            Object unit = jsonUnit.get("count");
            mapUnit = JSONObject.parseObject(unit.toString());

        }


        /**
         * 获取宣传教育材料上传数量
         */
        String orgName = ServiceUtil.getOrgName(request);
        if(StringUtils.isEmpty(orgName)) {
            return R.error("登录人所属机构不能为空");
        }
        orgName = orgName.replace("地震局", "");
        String eduMsg = HttpClientUtil.doGet(xcjyURL + "/material/mapCountByYearAndOrgName?year=" + year + "&orgName=" + orgName);
        Map<String, Object> eduMap = new HashMap<>();
        if(!StringUtils.isEmpty(eduMsg)) {
            JSONObject jsonEdu = JSON.parseObject(eduMsg);
            Object eduData = jsonEdu.get("data");
            eduMap = JSONObject.parseObject(eduData.toString());
        }

        List<Map<String, Object>> list = new ArrayList();
        list.add(mapCheck);
        list.add(mapPunish);
        list.add(mapForce);
        list.add(mapOther);
        list.add(mapCon);
        list.add(mapUnit);
        list.add(eduMap);
        Map<String, Object> mapAll = new HashMap<>();
        if(!list.isEmpty()){
            for (Map<String, Object> map : list) {
                for (Map.Entry<String, Object> entry : map.entrySet()) {
                    String key = entry.getKey();
                    Integer value = (Integer) entry.getValue();
                    Integer valueAll = (Integer) mapAll.get(entry.getKey());
                    if (valueAll == null) {
                        mapAll.put(key, value);
                    } else {
                        valueAll = valueAll.intValue() + value.intValue();
                        mapAll.put(key, valueAll);
                    }
                }
            }
        }
        List<Map<String, Object>> listNew = new ArrayList();
        Integer num = 0;
        for (Map.Entry<String, Object> entry : mapAll.entrySet()) {
                HashMap map = new HashMap();
                String name = entry.getKey();
                Integer value = (Integer) entry.getValue();
                num += value;
                map.put("name", name);
                map.put("value", value);
                listNew.add(map);
        }
        for(String arr:mapPro){
            HashMap mapNew=new HashMap();
            for (Map map:listNew) {
                String str=(String)map.get("name");
                if(!arr.equals(str)){
                    mapNew.put("name",arr);
                    mapNew.put("value",0);
                }
            }
            listNew.add(mapNew);
        }
        String data = JSON.toJSONString(listNew);
        return R.ok().put("data", data).put("cityTotal", num);
    }
    /**
     * @param year
     * @return
     */
    @GetMapping("/mapyear")
    public R getTotalByYearMap(String year, HttpServletRequest request) {
        String[] mapPro = new String[]{"南海诸岛", "北京", "天津", "上海", "重庆", "河北", "河南", "云南", "辽宁", "黑龙江", "湖南", "安徽", "山东", "新疆", "江苏", "浙江", "江西", "湖北", "广西", "甘肃", "山西", "内蒙古", "陕西", "吉林", "福建", "贵州", "广东", "青海", "西藏", "四川", "宁夏", "海南", "台湾", "香港", "澳门"};
        /***
         * 获取检查行为
         */
        String msg = HttpClientUtil.doGet(apURL + "/check/countbyyear?year=" + year);
        JSONObject jsonObject = JSON.parseObject(msg);
        Map<String, Object> mapCheck = new HashMap<>();
        if(!StringUtils.isEmpty(msg)){
            Object count = jsonObject.get("count");
            mapCheck = JSONObject.parseObject(count.toString());
        }
        /**
         * 获取处罚行为
         */
        String msgPunish = HttpClientUtil.doGet(apURL + "/punish/punishyear?year=" + year);
        JSONObject jsonPunish = JSON.parseObject(msgPunish);
        Map<String, Object> mapPunish = new HashMap<>();
        if(!StringUtils.isEmpty(msgPunish)) {
            Object punishOb = jsonPunish.get("count");
            mapPunish = JSONObject.parseObject(punishOb.toString());
        }
        /**
         * 获取强制行为
         */
        String msgForce = HttpClientUtil.doGet(apURL + "/force/forceyear?year=" + year);
        JSONObject jsonForce = JSON.parseObject(msgForce);
        Map<String, Object> mapForce = new HashMap<>();
        if(!StringUtils.isEmpty(msgForce)) {
            Object  forceOb = jsonForce.get("count");
            mapForce = JSONObject.parseObject(forceOb.toString());
        }

        /**
         * 获取其他行为
         */
        String msgOther = HttpClientUtil.doGet(apURL + "/other/otheryear?year=" + year);
        JSONObject jsonOther = JSON.parseObject(msgOther);
        Map<String, Object> mapOther = new HashMap<>();
        if(!StringUtils.isEmpty(msgOther)) {
            Object otherOb = jsonOther.get("count");
            mapOther = JSONObject.parseObject(otherOb.toString());
        }
        /**
         * 获取建设单位
         */
        String msgCon = HttpClientUtil.doGet(apURL + "/constr/countconstryear?year=" + year);
        JSONObject jsonCon = JSON.parseObject(msgCon);
        Map<String, Object> mapCon = new HashMap<>();
        if(!StringUtils.isEmpty(msgCon)) {
            Object constr = jsonCon.get("count");
            mapCon = JSONObject.parseObject(constr.toString());
        }
        /**
         * 获取安评单位
         */
        String msgUnit = HttpClientUtil.doGet(apURL + "/evalunit/countunityear?year=" + year);
        JSONObject jsonUnit = JSON.parseObject(msgUnit);
        Map<String, Object> mapUnit = new HashMap<>();
        if(!StringUtils.isEmpty(msgUnit)) {
            Object unit = jsonUnit.get("count");
            mapUnit = JSONObject.parseObject(unit.toString());

        }

        /**
         * 获取宣传教育材料上传数量
         */
        String orgName = ServiceUtil.getOrgName(request);
        if(StringUtils.isEmpty(orgName)) {
            return R.error("登录人所属机构不能为空");
        }
        orgName = orgName.replace("地震局", "");
        String eduMsg = HttpClientUtil.doGet(xcjyURL + "/material/mapCountByYearAndOrgName?year=" + year + "&orgName=" + orgName);
        Map<String, Object> eduMap = new HashMap<>();
        if(!StringUtils.isEmpty(eduMsg)) {
            JSONObject jsonEdu = JSON.parseObject(eduMsg);
            Object eduData = jsonEdu.get("data");
            eduMap = JSONObject.parseObject(eduData.toString());
        }

        List<Map<String, Object>> list = new ArrayList();
        list.add(mapCheck);
        list.add(mapPunish);
        list.add(mapForce);
        list.add(mapOther);
        list.add(mapCon);
        list.add(mapUnit);
        list.add(eduMap);
        Map<String, Object> mapAll = new HashMap<>();
        if(!list.isEmpty()){
            for (Map<String, Object> map : list) {
                for (Map.Entry<String, Object> entry : map.entrySet()) {
                    String key = entry.getKey();
                    Integer value = (Integer) entry.getValue();
                    Integer valueAll = (Integer) mapAll.get(entry.getKey());
                    if (valueAll == null) {
                        mapAll.put(key, value);
                    } else {
                        valueAll = valueAll.intValue() + value.intValue();
                        mapAll.put(key, valueAll);
                    }
                }
            }
        }
        List<Map<String, Object>> listNew = new ArrayList();
        Integer num = 0;
        for (Map.Entry<String, Object> entry : mapAll.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            num += value;
            map.put("name", name);
            map.put("value", value);
            listNew.add(map);
        }
        String data = JSON.toJSONString(listNew);
        return R.ok().put("data", data).put("cityTotal", num);
    }
    /***
     * 获取总数
     * @return
     */
    @GetMapping("/getCount")
    public R getTale(HttpServletRequest request) {
        /**
         * 获取建设单位
         */
        String msgCon = HttpClientUtil.doGet(apURL + "/constr/countconstr");
        JSONObject jsonCon = JSON.parseObject(msgCon);
        Map<String, Object> mapCon = new HashMap<>();
        int objCon = 0;
        if(!StringUtils.isEmpty(msgCon)) {
            Object constr = jsonCon.get("count");
            mapCon = JSONObject.parseObject(constr.toString());
            for (Map.Entry<String, Object> entry : mapCon.entrySet()) {
                Integer value = (Integer) entry.getValue();
                objCon += value;
            }
        }



        /**
         * 获取安评单位
         */
        String msgUnit = HttpClientUtil.doGet(apURL + "/evalunit/countunit");
        JSONObject jsonUnit = JSON.parseObject(msgUnit);
        Map<String, Object> mapUnit = new HashMap<>();
        int objUnit = 0;
        int objCount = 0 ;
        if(!StringUtils.isEmpty(msgUnit)) {
            Object unit = jsonUnit.get("count");
            mapUnit = JSONObject.parseObject(unit.toString());
            for (Map.Entry<String, Object> entry : mapUnit.entrySet()) {
                Integer value = (Integer) entry.getValue();
                objUnit += value;
            }
            objCount = objCon + objUnit;
        }

        /***
         * 获取检查行为
         */
        String msgCheck = HttpClientUtil.doGet(apURL + "/check/count");
        JSONObject jsonObject = JSON.parseObject(msgCheck);
        Map<String, Object> mapCheck = new HashMap<>();
        int behCheck = 0;
        if(!StringUtils.isEmpty(msgCheck)) {
            Object count = jsonObject.get("count");
            mapCheck = JSONObject.parseObject(count.toString());
            for (Map.Entry<String, Object> entry : mapCheck.entrySet()) {
                Integer value = (Integer) entry.getValue();
                behCheck += value;
            }
        }
        /**
         * 获取处罚行为
         */
        String msgPunish = HttpClientUtil.doGet(apURL + "/punish/punish");
        JSONObject jsonPunish = JSON.parseObject(msgPunish);
        Map<String, Object> mapPunish = new HashMap<>();
        int behPunish = 0;
        if(!StringUtils.isEmpty(msgPunish)) {
            Object punishOb = jsonPunish.get("count");
            mapPunish = JSONObject.parseObject(punishOb.toString());
            for (Map.Entry<String, Object> entry : mapPunish.entrySet()) {
                Integer value = (Integer) entry.getValue();
                behPunish += value;
            }
        }

        /**
         * 获取强制行为
         */
        String msgForce = HttpClientUtil.doGet(apURL + "/force/force");
        JSONObject jsonForce = JSON.parseObject(msgForce);
        Map<String, Object> mapForce = new HashMap<>();
        int behForce = 0;
        if(!StringUtils.isEmpty(msgForce)) {
            Object forceOb = jsonForce.get("count");
            mapForce = JSONObject.parseObject(forceOb.toString());
            for (Map.Entry<String, Object> entry : mapForce.entrySet()) {
                Integer value = (Integer) entry.getValue();
                behForce += value;
            }
        }


        /**
         * 获取其他行为
         */
        String msgOther = HttpClientUtil.doGet(apURL + "/other/other");
        JSONObject jsonOther = JSON.parseObject(msgOther);
        Map<String, Object> mapOther = new HashMap<>();
        int behOther = 0;
        if(!StringUtils.isEmpty(msgOther)) {
            Object otherOb = jsonOther.get("count");
            mapOther = JSONObject.parseObject(otherOb.toString());
            for (Map.Entry<String, Object> entry : mapOther.entrySet()) {
                Integer value = (Integer) entry.getValue();
                behOther += value;
            }
        }
        int behCount = behCheck + behForce + behOther + behPunish;


        /**
         * 获取宣传教育中材料上传的总数
         */
        int eduCount = 0;
        String orgName = ServiceUtil.getOrgName(request);
        if(!StringUtils.isEmpty(orgName)) {
            orgName = orgName.replace("地震局", "");
            String eduMsg = HttpClientUtil.doGet(xcjyURL + "/material/countByOrgName?orgName=" + orgName);
            if(!StringUtils.isEmpty(eduMsg)) {
                JSONObject jsonEdu = JSON.parseObject(eduMsg);
                eduCount = (int) jsonEdu.get("data");
            }
        }


        int totalCount = behCount + objCount + eduCount;
        return R.ok().put("objCount", objCount).put("behCount", behCount).put("totalCount", totalCount).put("eduCount", eduCount);
    }


    @GetMapping("/bing")
    public R getBing(String year) {
        /***
         * 获取检查行为
         */
        String msgCheck = HttpClientUtil.doGet(apURL + "/check/countbyyear?year=" + year);
        JSONObject jsonObject = JSON.parseObject(msgCheck);
        Object count = jsonObject.get("count");
        Map<String, Object> mapCheck = JSONObject.parseObject(count.toString());
        List listCheck = new ArrayList();
        List<String> check = new ArrayList<>();
        for (Map.Entry<String, Object> entry : mapCheck.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            map.put("name", name);
            map.put("value", value);
            listCheck.add(map);
            check.add(name);
        }
        String dataCheck = JSON.toJSONString(listCheck);
        /**
         * 获取处罚行为
         */
        String msgPunish = HttpClientUtil.doGet(apURL + "/punish/punishyear?year=" + year);
        JSONObject jsonPunish = JSON.parseObject(msgPunish);
        Object punishOb = jsonPunish.get("count");
        Map<String, Object> mapPunish = JSONObject.parseObject(punishOb.toString());
        List listPunish = new ArrayList();
        List<String> punish = new ArrayList<>();
        for (Map.Entry<String, Object> entry : mapPunish.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            map.put("name", name);
            map.put("value", value);
            listPunish.add(map);
            punish.add(name);
        }
        String dataPunish = JSON.toJSONString(listPunish);
        /**
         * 获取强制行为
         */
        String msgForce = HttpClientUtil.doGet(apURL + "/force/forceyear?year=" + year);
        JSONObject jsonForce = JSON.parseObject(msgForce);
        Object forceOb = jsonForce.get("count");
        Map<String, Object> mapForce = JSONObject.parseObject(forceOb.toString());
        List listForce = new ArrayList();
        List<String> force = new ArrayList<>();
        for (Map.Entry<String, Object> entry : mapForce.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            map.put("name", name);
            map.put("value", value);
            listForce.add(map);
            force.add(name);
        }
        String dataForce = JSON.toJSONString(listForce);
        /**
         * 获取其他行为
         */
        String msgOther = HttpClientUtil.doGet(apURL + "/other/otheryear?year=" + year);
        JSONObject jsonOther = JSON.parseObject(msgOther);
        Object otherOb = jsonOther.get("count");
        Map<String, Object> mapOther = JSONObject.parseObject(otherOb.toString());
        List listOther = new ArrayList();
        List<String> other = new ArrayList<>();
        for (Map.Entry<String, Object> entry : mapOther.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            map.put("name", name);
            map.put("value", value);
            listOther.add(map);
            other.add(name);
        }
        String dataOther = JSON.toJSONString(listOther);
        /**
         * 获取建设单位
         */
        String msgCon = HttpClientUtil.doGet(apURL + "/constr/countconstryear?year=" + year);
        JSONObject jsonCon = JSON.parseObject(msgCon);
        Object constr = jsonCon.get("count");
        Map<String, Object> mapCon = JSONObject.parseObject(constr.toString());
        List listContr = new ArrayList();
        for (Map.Entry<String, Object> entry : mapCon.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            map.put("name", name);
            map.put("value", value);
            listContr.add(map);
        }
        String dataConstr = JSON.toJSONString(listContr);
        /**
         * 获取安评单位
         */
        String msgUnit = HttpClientUtil.doGet(apURL + "/evalunit/countunityear?year=" + year);
        JSONObject jsonUnit = JSON.parseObject(msgUnit);
        Object unit = jsonUnit.get("count");
        Map<String, Object> mapUnit = JSONObject.parseObject(unit.toString());
        List listUnit = new ArrayList();
        for (Map.Entry<String, Object> entry : mapUnit.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            map.put("name", name);
            map.put("value", value);
            listUnit.add(map);
        }
        String dataUnit = JSON.toJSONString(listUnit);
        return R.ok().put("dataCheck", dataCheck).put("dataPunish", dataPunish).
                put("dataForce", dataForce).put("dataOther", dataOther).put("dataUnit", dataUnit).put("dataConstr", dataConstr);
    }

    @GetMapping("/bar")
    public R getBar(String year) {
        /***
         * 获取检查行为
         */
        String msgCheck = HttpClientUtil.doGet(apURL + "/check/countbyyear?year=" + year);
        JSONObject jsonObject = JSON.parseObject(msgCheck);
        Object count = jsonObject.get("count");
        Map<String, Object> mapCheck = JSONObject.parseObject(count.toString());
        List listCheck = new ArrayList();
        List<String> check = new ArrayList<>();
        /**
         * 获取处罚行为
         */
        String msgPunish = HttpClientUtil.doGet(apURL + "/punish/punishyear?year=" + year);
        JSONObject jsonPunish = JSON.parseObject(msgPunish);
        Object punishOb = jsonPunish.get("count");
        Map<String, Object> mapPunish = JSONObject.parseObject(punishOb.toString());
        List<String> punish = new ArrayList<>();
        List listPunish = new ArrayList();
        /**
         * 获取强制行为
         */
        String msgForce = HttpClientUtil.doGet(apURL + "/force/forceyear?year=" + year);
        JSONObject jsonForce = JSON.parseObject(msgForce);
        Object forceOb = jsonForce.get("count");
        Map<String, Object> mapForce = JSONObject.parseObject(forceOb.toString());
        List listForce = new ArrayList();
        List<String> force = new ArrayList<>();

        /**
         * 获取其他行为
         */
        String msgOther = HttpClientUtil.doGet(apURL + "/other/otheryear?year=" + year);
        JSONObject jsonOther = JSON.parseObject(msgOther);
        Object otherOb = jsonOther.get("count");
        Map<String, Object> mapOther = JSONObject.parseObject(otherOb.toString());
        List listOther = new ArrayList();
        List<String> other = new ArrayList();

        /**
         * 获取建设单位
         */
        String msgCon = HttpClientUtil.doGet(apURL + "/constr/countconstryear?year=" + year);
        JSONObject jsonCon = JSON.parseObject(msgCon);
        Object constr = jsonCon.get("count");
        Map<String, Object> mapCon = JSONObject.parseObject(constr.toString());
        List listContr = new ArrayList();

        /**
         * 获取安评单位
         */
        String msgUnit = HttpClientUtil.doGet(apURL + "/evalunit/countunityear?year=" + year);
        JSONObject jsonUnit = JSON.parseObject(msgUnit);
        Object unit = jsonUnit.get("count");
        Map<String, Object> mapUnit = JSONObject.parseObject(unit.toString());
        List listUnit = new ArrayList();
        /***
         * 获取检查行为的机构
         */
        for (Map.Entry<String, Object> entry : mapCheck.entrySet()) {
            String name = entry.getKey();
            check.add(name);
        }
        /***
         * 获取处罚行为的机构
         */
        for (Map.Entry<String, Object> entry : mapPunish.entrySet()) {
            String name = entry.getKey();
            punish.add(name);
        }
        /**
         * 获取强制行为的机构
         */
        for (Map.Entry<String, Object> entry : mapForce.entrySet()) {
            String name = entry.getKey();
            force.add(name);
        }
        /***
         * 获取其他行为的机构
         */
        for (Map.Entry<String, Object> entry : mapOther.entrySet()) {
            String name = entry.getKey();
            other.add(name);
        }
        for (String chk : check) {
            if (!punish.contains(chk)) {
                mapPunish.put(chk, 0);
            }
            if (!force.contains(chk)) {
                mapForce.put(chk, 0);
            }
            if (!other.contains(chk)) {
                mapOther.put(chk, 0);
            }
        }
        for (String pun : punish) {
            if (!check.contains(pun)) {
                mapCheck.put(pun, 0);
            }
            if (!force.contains(pun)) {
                mapForce.put(pun, 0);
            }
            if (!other.contains(pun)) {
                mapOther.put(pun, 0);
            }
        }
        for (String fore : force) {
            if (!check.contains(fore)) {
                mapCheck.put(fore, 0);
            }
            if (!punish.contains(fore)) {
                mapPunish.put(fore, 0);
            }
            if (!other.contains(fore)) {
                mapOther.put(fore, 0);
            }
        }
        for (String oth : other) {
            if (!check.contains(oth)) {
                mapCheck.put(oth, 0);
            }
            if (!force.contains(oth)) {
                mapForce.put(oth, 0);
            }
            if (!punish.contains(oth)) {
                mapPunish.put(oth, 0);
            }
        }
        /**
         * 获取建设单位地址
         */
        List<String> listCon = new ArrayList<>();
        for (Map.Entry<String, Object> entry : mapCon.entrySet()) {
            String name = entry.getKey();
            listCon.add(name);
        }
        /***
         * 获取安评单位地址
         */
        List<String> listUni = new ArrayList<>();
        for (Map.Entry<String, Object> entry : mapUnit.entrySet()) {
            String name = entry.getKey();
            listUni.add(name);
        }
        for (String con : listCon) {
            if (!listUni.contains(con)) {
                mapUnit.put(con, 0);
            }
        }
        for (String uni : listUni) {
            if (!listCon.contains(uni)) {
                mapCon.put(uni, 0);
            }
        }

        for (Map.Entry<String, Object> entry : mapCon.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            map.put("name", name);
            map.put("value", value);
            listContr.add(map);
        }
        String dataConstr = JSON.toJSONString(listContr);

        for (Map.Entry<String, Object> entry : mapUnit.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            map.put("name", name);
            map.put("value", value);
            listUnit.add(map);
        }
        String dataUnit = JSON.toJSONString(listUnit);
        for (Map.Entry<String, Object> entry : mapCheck.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            map.put("name", name);
            map.put("value", value);
            listCheck.add(map);
        }
        String dataCheck = JSON.toJSONString(listCheck);

        for (Map.Entry<String, Object> entry : mapPunish.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            map.put("name", name);
            map.put("value", value);
            listPunish.add(map);
        }
        String dataPunish = JSON.toJSONString(listPunish);

        for (Map.Entry<String, Object> entry : mapForce.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            map.put("name", name);
            map.put("value", value);
            listForce.add(map);
        }
        String dataForce = JSON.toJSONString(listForce);

        for (Map.Entry<String, Object> entry : mapOther.entrySet()) {
            HashMap map = new HashMap();
            String name = entry.getKey();
            Integer value = (Integer) entry.getValue();
            map.put("name", name);
            map.put("value", value);
            listOther.add(map);
        }
        String dataOther = JSON.toJSONString(listOther);
        return R.ok().put("dataCheck", dataCheck).put("dataPunish", dataPunish).
                put("dataForce", dataForce).put("dataOther", dataOther).put("dataUnit", dataUnit).put("dataConstr", dataConstr);
    }

}
